import { ListPage } from "custom/index";
import { getPerformancePage } from './api'
import { exceedingFlagOptions } from './constant'
import dayjs from 'dayjs'
import performanceDetailDialog from './dialog/performance-detail-dialog'
import ReceptionVolumeColumn from './component/ReceptionVolumeColumn.vue'
import ConversionRateColumn from './component/ConversionRateColumn.vue'
import ResponseTimeColumn from './component/ResponseTimeColumn.vue'

const getParams = ctx => {
  const { props } = ctx
  return { url: 'DataQueryAnalysis2', condition: props.query, sort: props.sort }
}

const page = new ListPage('DayPage');

page
  .api(getPerformancePage)
  .useSearch()
    .useInputItem('keyword', '客户名称/店铺名称').showColumns(false).end()
    .addSelect({ prop: 'exceedingFlag', label: '是否超标' }, exceedingFlagOptions)
    .useDateRangePicker(['dateStart', 'dateEnd'], { label: '日期', clearable: false }).setDefault(dayjs().subtract(2, 'day').format('YYYY-MM-DD'), 'dateStart').setDefault(dayjs().subtract(1, 'day').format('YYYY-MM-DD'), 'dateEnd').upto('PageSearch')
    .end()
  .useTable()
    .useIndexColumn().end()
    .useColumn('dateStart').label('开始日期').minWidth(140).end()
    .useColumn('dateEnd').label('截止日期').minWidth(140).end()
    .useColumn('platformName').label('平台').minWidth(120).end()
    .useColumn('customerName').label('客户名称').minWidth(140).end()
    // .useColumn('platformName').label('客户名称').minWidth(140).end()
    .useColumn('shopName').label('店铺名称').minWidth(180).end()
    .useColumn('customTypeName').label('客服类型').minWidth(140).end()
    .useColumn('salesRevenue').label('销售额').minWidth(140).end()
    .useCustomColumn(ReceptionVolumeColumn, 'receptionVolume').label('接待量').minWidth(140).end()
    .useCustomColumn(ConversionRateColumn, 'conversionRate').label('转化率').minWidth(140).end()
    .useCustomColumn(ResponseTimeColumn, 'responseTime').label('响应时间').minWidth(140).end()
    .useColumn('qaratio').label('问答比').percent().minWidth(140).end()
    .useColumn('responseRate').label('回复率').percent().minWidth(140).end()
    .end()
  .usePagination()
    .end()
  .useAuthColumn()
    .useItem('').content('详情').editRow(performanceDetailDialog).end()
    .end()
  .useAuthButton()
    .useItem('').content('导出').exportExcel(getParams).end()

export default page
